package com.ctshk.task.worker.processors;

import com.ctshk.rpc.localfun.service.ILocalFunAppProductService;
import com.github.kfcfans.powerjob.worker.core.processor.ProcessResult;
import com.github.kfcfans.powerjob.worker.core.processor.TaskContext;
import com.github.kfcfans.powerjob.worker.core.processor.sdk.BasicProcessor;
import com.github.kfcfans.powerjob.worker.log.OmsLogger;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

/**
 * @Description APP/H5 当地玩乐信息缓存ES
 * @Author wansi <gaylen15527491065@yeah.net>
 * @Date 2021/6/10
 */
@Slf4j
@Component
public class AppLocalFunInfoCacheProcessor implements BasicProcessor {

    @DubboReference
    private ILocalFunAppProductService iLocalFunAppProductService;
    @Override
    public ProcessResult process(TaskContext taskContext) throws Exception {
        OmsLogger omsLogger = taskContext.getOmsLogger();
        try {
            iLocalFunAppProductService.cacheInit();
        } catch (Exception e) {
            omsLogger.info("PC/H5 当地玩乐信息缓存ES:{} .", e.getMessage());
        }
        // 根据控制台参数判断是否成功
        boolean success = !"failed".equals(taskContext.getJobParams());
        omsLogger.info("AppLocalFunInfoCacheProcessor finished process,success: .", success);
        return new ProcessResult(success, taskContext + ": " + success);
    }
}
